<template>
  <div class="index_wrapper">
    <div class="index_inner">
      <Top ></Top>
      <div class="main_wrapper">
        <div class="main_inner" style="display: flex">
          <LeftList></LeftList>
          <div class="main_wrapper" style="border: 0px solid blue;width: 100%;height: 600px;
          background-color: lightgray;">
            <router-view></router-view>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {postRequest} from "../utils/api";
  import Top from "./Top";
  import LeftList from "./LeftList";
  import {mapGetters, mapState} from 'vuex';
  import Fanyi from "./Fanyi";
  export default {
      name: "Index",
      data(){
        return {
        }
      },
      computed:{
        ...mapState(['userinfo']),
        ...mapGetters({asd:'inc_inc'})
      },
      methods: {
        inc(){
          this.$store.commit('increment')
        },
        getUserInfo(){
          console.debug("enter getUserInfo ")
          let param = {
            token: window.localStorage.getItem("token")
          }
          console.debug("token param:"+JSON.stringify(param))
          postRequest('/user_consumer/getUserByToken', param).then(res=>{
            console.debug("正常返回："+JSON.stringify(res.data))
            if(res.data.code==111){
              this.$router.replace("/login")
            }else {
              this.$store.commit('setUserInfo', res.data.t)
              // this.userinfo = res.data.t
            }
          }).catch(err=>{
            console.debug("异常返回："+JSON.stringify(err))
          })
        },
        getSysFeatures(){
          var token = window.localStorage.getItem("token")
          let param = {
            token: token
          }
          postRequest("feature_consumer/getSysFeatures", param).then(res=>{
            console.debug("正常返回 res:"+JSON.stringify(res))
            this.$message({showClose:true, message: "获取系统特征成功", type: 'success'})
            this.$store.commit("setSysFeatures", res.data.t)
          }).catch(err=>{
            console.debug("错误返回 err："+JSON.stringify(err))
            this.$message({showClose:true, message: JSON.stringify(err), type: 'err'})
          })
        }
      },
      mounted() {
        console.debug("enter mounted")
        this.getUserInfo()
        this.getSysFeatures()
      },
      components: {Top, LeftList, Fanyi}
  }
</script>

<style scoped>

</style>
